﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using G.WeiBo.WebAPI;
using G.WeiBo.WebAPI.Domain;

namespace G.WeiBo
{
    public static class GlobalStaticData
    {
        private static DefaultClient client;
        public static DefaultClient Client
        {
            get
            {
                if (client == null)
                    client = new DefaultClient();
                return client;
            }
        }

        private static UserInfo userInfo;
        public static UserInfo UserInfo
        {
            get
            {
                if (userInfo == null)
                {
                    if (System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings.Contains("UserInfo"))
                        userInfo = System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings["UserInfo"] as UserInfo;
                }
                return userInfo;
            }
            set
            {
                if (userInfo != value)
                {
                    userInfo = value;
                    System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings["UserInfo"] = value;
                    System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings.Save();
                }
            }
        }
    }
}
